package edu.gdut.tiantian.service.Impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;

import edu.gdut.tiantian.dao.CategoryDao;
import edu.gdut.tiantian.entity.Category;
import edu.gdut.tiantian.service.ICategoryService;

@Service
public class CategoryService implements ICategoryService {
	
	@Autowired
	private CategoryDao categoryDao;
	
	@Override
	public void saveCategory(Category category) {
		categoryDao.saveCategory(category);
	}

	@Override 
	public void delCategory(Integer categoryId) {
		categoryDao.delCategory(categoryId); 
	}

	@Override
	public void updateCategory(Category category) {
		categoryDao.updateCategory(category);
	}

	@Override
	public Category findById(Integer categoryId) {
		return categoryDao.findById(categoryId);
	}

	@Override
	public List<Category> findByCondition(Map<String,String> condition,int pageNum,int size) {
		PageHelper.startPage(pageNum, size);
		return categoryDao.findByCondition(condition);
	}

	@Override
	public List<Category> findAll() {
		return categoryDao.findAll();
	}

}
